<template>
  <view class="machine-bind-page">
    <view class="header">
      <text class="title">机具绑定</text>
    </view>
    
    <view class="form">
      <input v-model="possn" placeholder="请输入机身号" class="input" />
      <button @click="bindMachine" class="btn">绑定机具</button>
    </view>
    
    <view class="result">
      <text>{{ result }}</text>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'
import { post } from '@/utils/http'
import { ApitestUrl } from '@/utils/api'

const possn = ref('')
const result = ref('')

const bindMachine = async () => {
  try {
    const response = await post(ApitestUrl + '/api/LishuaCallback/bindMachine', {
      possn: possn.value
    })
    result.value = JSON.stringify(response)
  } catch (error) {
    result.value = '错误: ' + error.message
  }
}
</script>

<style>
.machine-bind-page {
  padding: 20px;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.title {
  font-size: 24px;
  font-weight: bold;
}

.form {
  margin-bottom: 20px;
}

.input {
  width: 100%;
  height: 40px;
  border: 1px solid #ccc;
  padding: 0 10px;
  margin-bottom: 10px;
}

.btn {
  width: 100%;
  height: 40px;
  background: #007aff;
  color: white;
  border: none;
  border-radius: 4px;
}

.result {
  background: #f5f5f5;
  padding: 10px;
  border-radius: 4px;
}
</style>
